//
//  ListSearchExt.swift
//  ANOA
//
//  Created by 邱仙凯 on 2024/12/30.
//  Copyright © 2024 zwb. All rights reserved.
//

import UIKit

extension KSTempListVC {
    func configFilter() {
        
        
 
       
        
        var yyy:CGFloat = 0
        if TempAppear.shared.newFilterStyle {
            
            let itemXYNew = self.view.convert(filterBanner.frame, to: getKeyWindow()!)
            
            yyy = itemXYNew.maxY
            
       }
  
        self.filterBanner.initWithFcontent(startY:yyy,templateFilter: templateFilter,rootTemp:rootTemp)
        self.filterBanner.bannerComfirmClo = {
            if let isrefresh = self.tableView.mj_header?.isRefreshing,isrefresh {
                self.tableView.mj_header?.endRefreshing()
                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
                    self.tableView.mj_header?.beginRefreshing()
                }
            }  else {
                self.tableView.mj_header?.beginRefreshing()
            }
        }
  
        configRightItem()
        
      
    }

    

   
    func configRightItem() {
        var items = [UIBarButtonItem]()
        if rootTemp.scanOutsideParam != "" {
            items += [scanItem]
        }
        if rootTemp.save_url != "" &&  !rootTemp.setAddForbidden {
            if TempAppear.shared.chineseDescription {
                items += [addItem_ch]
            } else {
                items += [addItem]
            }
           
        }
        let ssF = filterBanner.filterV!.templateFilter.filter{$0.isFilterShow == "1"}
        if ssF.count > 0 {
            if TempAppear.shared.newFilterStyle {
                self.view.addSubview(filterBanner)
             
              
            } else {
 
                if TempAppear.shared.chineseDescription {
                    items += [searchItem_ch]
                } else {
                    items += [searchItem]
                }
            }
            
            
        } else {
            remakeTableView(topM: 0)
        }
        
        
        navigationItem.rightBarButtonItems = items
        if let clo = self.configRightClo {
            clo()
        }
    }
    //MARK: -- 展开过滤界面
    @objc func tempSearchAction() {
      
 
        
        self.filterBanner.filterV!.showFilterV()
        
        
    }
}

